<?php
class retrieve_guestbook_admin extends retrieve_base{

	private $module_display_options 	= array(
		array("GUESTBOOK_DISPLAY",	LOCALE_DISPLAY_GUESTBOOK)
	);

		/**
	* function produces abstract structure of modules db structure
	*
    * used to generate the table structure required abstract function that passes an abstract
	* representation of the desired table structure to the proper database module which will
	* interpet the abstract and convert it into a valid SQL Create table structure.
	*
	* @return Array list of abstract table definitions for this module
	*/
	function create_table(){
		$tables = array();
		/**
		* Table structure for table 'guestbooks_list'
		-
		* the guest books_list table holds the list of guset books that are avaialble on the site
		*/
		$fields = array(
		array("gb_identifier"		,"unsigned integer"			,"NOT NULL"	,"auto_increment","key"),
		array("gb_client"			,"unsigned integer"			,"NOT NULL"	,"default '0'"),
		array("gb_label"			,"varchar(255)"				,"NOT NULL"	,"default '0'"),
		array("gb_creation_date"	,"datetime"					,"NOT NULL"	,"default ''"),
		array("gb_status"			,"unsigned integer"			,"NOT NULL"	,"default '0'","key"),
		array("gb_workflow_status"	,"unsigned integer"			,"NOT NULL"	,"default '0'","key"),
		array("gb_menu_locations"	,"unsigned integer"			,"NOT NULL" ,"default '0'","key"),
		array("gb_display_format"	,"unsigned small integer"	,"NOT NULL" ,"default '1'","key")
		);
		
		$primary ="gb_identifier";
		$tables[count($tables)] = array("guestbooks_list", $fields, $primary);
		/**
		* Table structure for table 'guestbooks_status'
		*/
		$fields = array(
		array("gbs_identifier"		,"unsigned integer"			,"NOT NULL"	,"auto_increment","key"),
		array("gbs_label"			,"varchar(255)"				,"NOT NULL"	,"default ''")
		);
		$data = array(
		'INSERT INTO guestbooks_status (gbs_label) VALUES ("Not Live");',
		'INSERT INTO guestbooks_status (gbs_label) VALUES ("Live (open)");',
		'INSERT INTO guestbooks_status (gbs_label) VALUES ("Live (closed)");'
		
		);
		
		$primary ="gbs_identifier";
		$tables[count($tables)] = array("guestbooks_status", $fields, $primary, $data);
		/**
		* Table structure for table 'guestbooks_workflow_status'
		-
		* 1. Everyone can publish directly to the site
		* 2. registered users can publish to the site directly, anonymous to be approved
		* 3. no anonymous acces to add functions
		* 4. all content to be approved unless user has approval status set.
		*/
		$fields = array(
		array("gbws_identifier"		,"unsigned integer"			,"NOT NULL"	,"auto_increment","key"),
		array("gbws_label"			,"varchar(255)"				,"NOT NULL"	,"default '0'")
		);
		$data = array(
		'INSERT INTO guestbooks_workflow_status (gbws_label) VALUES ("LOCALE_GUESTBOOK_WORKFLOW_STATUS_FREE_ACCESS");',
		'INSERT INTO guestbooks_workflow_status (gbws_label) VALUES ("LOCALE_GUESTBOOK_WORKFLOW_STATUS_REG_PUB");',
		'INSERT INTO guestbooks_workflow_status (gbws_label) VALUES ("LOCALE_GUESTBOOK_WORKFLOW_STATUS_LOGGED_IN");',
		'INSERT INTO guestbooks_workflow_status (gbws_label) VALUES ("LOCALE_GUESTBOOK_WORKFLOW_STATUS_CLOSED");'
		);
		$primary ="gbws_identifier";
		$tables[count($tables)] = array("guestbooks_workflow_status", $fields, $primary, $data);
		/**
		* Table structure for table 'guestbooks_entry_status'
		*/
		$fields = array(
		array("gbes_identifier"		,"unsigned integer"			,"NOT NULL"	,"auto_increment","key"),
		array("gbes_label"			,"varchar(255)"				,"NOT NULL"	,"default '0'")
		);
		$data = array(
		'INSERT INTO guestbooks_entry_status (gbes_label) VALUES ("Requires Approval");',
		'INSERT INTO guestbooks_entry_status (gbes_label) VALUES ("Approved");'
		);
		
		$primary ="gbes_identifier";
		$tables[count($tables)] = array("guestbooks_entry_status", $fields, $primary, $data);
		/**
		* Table structure for table 'guestbooks_entry'
		-
		* log_details is a relationship link to the users session logs record
		* gbes_book is a relationship with the guestbooks_list
		*/
		$fields = array(
		array("gbe_identifier"		,"unsigned integer"			,"NOT NULL"	,"auto_increment", "key"),
		array("gbe_book"			,"unsigned integer"			,"NOT NULL"	,"default '0'", "key"),
		array("gbe_client"			,"unsigned integer"			,"NOT NULL"	,"default '0'", "key"),
		array("gbe_user"			,"unsigned integer"			,"NOT NULL"	,"default '0'", "key"),
		array("gbe_log_details"		,"unsigned integer"			,"NOT NULL"	,"default '0'", "key"),
		array("gbe_creation_date"	,"datetime"					,"NOT NULL"	,"default ''"),
		array("gbe_label"			,"varchar(255)"				,"NOT NULL"	,"default '0'"),
		array("gbe_name"			,"varchar(255)"				,"NOT NULL"	,"default ''"),
		array("gbe_status"			,"unsigned small integer"	,"NOT NULL" ,"default '0'", "key"),
		array("gbe_approved_by"		,"unsigned integer"			,"NOT NULL"	,"default '0'", "key")
		);
		
		$primary ="gbe_identifier";
		$tables[count($tables)] = array("guestbooks_entry", $fields, $primary);
		
		
		return $tables;
	}
}
?>